home *** CD-ROM | disk | FTP | other *** search
- real p0[], p1[], p2[], p3[];
- real timeArray[]; ** for discrete event Exec testing
- integer in0;
-
- ** This plotter overlays inputs from different simulations
- ** for easy comparison.
- ** Copyright © 1989-1994 by Imagine That, Inc.
- ** All Rights Reserved.
- ** Extend Plotter Library, Plotter Multisim block;Alfy Riddle 8/15/89
- ** modified 1/1/92 JSL Modified for V2.0
- ** 12/8/92 JSL added numSims > 1 to initSim code
- ** 4/1/94 DJK modified trace and report
- ** 6/2/94 DJK added openModel message handler
-
- on checkData
- {
- sysGlobal1 = 0.0;
- sysGlobal2 = 0.0;
-
- ** Find out if inputs are connected to determine
- ** which are being used as input or output
- ** and save their states for plotting decisions
- ** in simulate message
- in0 = Con0In; ** save values for later decisions
- }
-
-
- on initsim
- {
- ** First check to make sure Discrete Event Exec is not being used
- if( getPassedArray(sysGlobal0, timeArray) )
- {
- userError("The Plotter, MultiSim does not work with the Discrete Event Exec in block number "+(MyBlockNumber()));
- abort;
- }
-
- ** if no inputs are connected, don't do anything
- ** so that the user can use the saved data for input
- if (not in0)
- return;
-
- ** check each input connector. If it is connected
- ** the user is using that signal to plot simulation
- ** results, so resize the array using makeArray.
-
- ** If it isn't used, compress the signal array
-
- if( nextLine == 1 || (currentSim == 0 && numSims > 1) )
- {
- makeArray(p0, numsteps); ** yes, input. Resize array
- installArray(0, 0, "", p0, startTime, endTime,
- 0, 0, blackPattern, cyanColor);
- }
- if( nextLine == 2 || (currentSim == 0 && numSims > 1) )
- {
- makeArray(p1, numsteps); ** yes, input. Resize array
- installArray(0, 1, "", p1, startTime, endTime,
- 0, 0, dkgrayPattern, redColor);
- }
- if( nextLine == 3 || (currentSim == 0 && numSims > 1) )
- {
- makeArray(p2, numsteps); ** yes, input. Resize array
- installArray(0, 2, "", p2, startTime, endTime,
- 0, 0, grayPattern, greenColor);
- }
- if( nextLine == 4 || (currentSim == 0 && numSims > 1) )
- {
- makeArray(p3, numsteps); ** yes, input. Resize array
- installArray(0, 3, "", p3, startTime, endTime,
- 0, 0, ltgrayPattern, blackColor);
- }
-
- retimeAxis(0);
-
- if( showDuring )
- showPlot(0, "Plotter, Multisim");
- }
-
-
- on simulate
- {
- ** check each saved input connector state
-
- ** if it is TRUE, the input connector was
- ** connected, so plot the new point and also
- ** pass the value to the output in case it is
- ** also connected.
-
- ** if it is FALSE, the input connector wasn't
- ** connected, so get the output value from
- ** the previously stored signal in the plot
- ** and put it in the output connector
-
- if( nextLine == 1 )
- {
- plotNewPoint(0,0,currentStep,con0in);
- }
- else if( nextLine == 2 )
- {
- plotNewPoint(0,1,currentStep,con0in);
- }
- else if( nextLine == 3 )
- {
- plotNewPoint(0,2,currentStep,con0in);
- }
- else if( nextLine == 4 )
- {
- plotNewPoint(0,3,currentStep,con0in);
- }
-
- ** sysGlobal2 is the file reference number for the DEBUG TRACE
- if( sysGlobal2 != 0.0 ) ** 0 is error, check for open file for TRACE
- {
- // template for trace: |BLOCK NAME *****************|block number |BLOCK NUMBER*******|.| Current Time:|CURRENTTIME |.|
- fileWrite(sysGlobal2,"Plotter,Multisim block number "+(myBlockNumber())+". Current Time:"+currentTime+".","",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal2,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- fileWrite(sysGlobal2," Input = "+con0In,"",True);
- fileWrite(sysGlobal2," ","",True);
- }
- }
-
-
- on endsim
- {
- integer i, loop;
- integer size0, size1, size2, size3;
- string str;
-
- if( autoIncr )
- nextLine = (nextLine mod 4) + 1;
-
- if( Con0In and showEnd and (numsims == (currentsim + 1)) ) // show plot at end if selected
- showPlot(0, "Plotter, Multisim");
-
- if( in0 )
- pushPlotPic(0);
-
- ** sysGlobal1 is the file reference number for the TEXT REPORT
- if( sysGlobal1 != 0.0 ) ** 0 is error, check for open file for REPORT
- {
- // template for report: |BLOCK NAME *****************|block number |BLOCK NUMBER*******
- fileWrite(sysGlobal1,"Plotter, Multisim block number "+(myBlockNumber()),"",True);
- if(getBlockLabel(myBlockNumber()) != "")
- fileWrite(sysGlobal1,"Block Label: "+getBlockLabel(myBlockNumber()),"",True);
- if( comments != "" )
- fileWrite(sysGlobal1," "+comments,"",True);
- fileWrite(sysGlobal1," Input Parameters:","",True);
- if( showDuring )
- fileWrite(sysGlobal1," Plot is shown during simulation","",True);
- else
- fileWrite(sysGlobal1," Plot is hidden during simulation","",True);
-
- if( !noValue(nextLine) )
- fileWrite(sysGlobal1," Next plot line = "+nextLine,"",True);
-
- size0 = GetDimension(p0);
- size1 = GetDimension(p1);
- size2 = GetDimension(p2);
- size3 = GetDimension(p3);
-
- i = 0;
- loop = TRUE;
- while(loop)
- {
- str = "";
- if (i < size0)
- str = p0[i];
- str += " ";
- if (i < size1)
- str += p1[i];
- str += " ";
- if (i < size2)
- str += p2[i];
- str += " ";
- if (i < size3)
- str += p3[i];
-
- fileWrite(sysGlobal1, str, "", true);
- i++;
- if (i >= numSteps-1)
- {
- loop = FALSE;
- break;
- }
- if (i >= size0 && i >= size1 && i >= size2 && i >= size3)
- loop = FALSE;
- }
- fileWrite(sysGlobal1," ","",True);
- }
- }
-
-
- on dialogOpen
- {
- showplot(0, "Plotter, MultiSim");
- abort; ** stop the dialog from opening!
- }
-
-
- on showP
- {
- showplot(0, "Plotter, MultiSim");
- }
-
- on createBlock
- {
- ** First check to make sure Discrete Event Exec is not being used
- if( getPassedArray(sysGlobal0, timeArray) )
- {
- userError("The Plotter, MultiSim does not work with the Discrete Event Exec in block number "+MyBlockNumber());
- abort;
- }
-
- ** install a dummy axis
- installAxis(0, "Plotter, MultiSim", "Time", FALSE, 0.0, 1.0,
- "Value", 0, -1.0, 1.0, "Y2", 0, 0.0, 0.0,
- blackpattern, blackcolor, 100);
-
- ** now, install 4 dummy array signals
- ** to store plotting values from a simulation
- ** or from Pasting (Importing) tabular data
-
- makeArray(p0, 0);
- installArray(0, 0, "Blue", p0, 0.0, 1.0,
- 0, 0, blackPattern, cyanColor);
- makeArray(p1, 0);
- installArray(0, 1, "Red", p1, 0.0, 1.0,
- 0, 0, dkgrayPattern, redColor);
- makeArray(p2, 0);
- installArray(0, 2, "Green", p2,0.0, 1.0,
- 0, 0, grayPattern, greenColor);
- makeArray(p3, 0);
- installArray(0, 3, "Gray", p3, 0.0, 1.0,
- 0, 0, ltgrayPattern, blackColor);
-
- showDuring = 1; ** default show plot during simulation
- nextLine = 1;
- autoIncr = 1; ** auto step plot line used
- }
-
-
- on openModel
- {
- if(!showDuring && !showEnd && !noPlot)
- noPlot = 1;
- }